#ifndef _LINKEDLIST_H_
#define _LINKEDLIST_H_

typedef struct ll_node {
	struct ll_node *next;
	void *data;
} ll_node_t;

typedef struct {
	ll_node_t *head;
	ll_node_t *tail;
	unsigned int count;
} ll_list_t;

/**
 * Returns the data on the front of the list.
 */
void *ll_get_front(ll_list_t *list);

/**
 * Returns the data on the back of the list.
 */
void *ll_get_back(ll_list_t *list);

/**
 * Adds data to the front of the list and returns the new node.
 * Returns NULL on error.
 */
ll_node_t *ll_add_front(ll_list_t *list, void *data);

/**
 * Adds data to the back of the list and returns the new node.
 * Returns NULL on error.
 */
ll_node_t *ll_add_back(ll_list_t *list, void *data);

/**
 * Removes the first node from the list and returns its data.
 */
void *ll_remove_front(ll_list_t *list);

/**
 * Removes the last node from the list and returns its data.
 */
void *ll_remove_back(ll_list_t *list);

/**
 * Inserts data into a list after prevNode and returns the new node.
 */
ll_node_t *ll_insert(ll_list_t *list, ll_node_t *prevNode, void *data);

/**
 * Removes a node from the list and returns its data.
 */
void *ll_remove(ll_list_t *list, ll_node_t *node);

/**
 * Removes all nodes from the list and optionally frees the data.
 */
void ll_clear(ll_list_t *list, int freeContents);

#endif

